package org.ssm.learn;

import java.io.IOException;
import java.io.PipedInputStream;

public class ReadData {

    public void readMethod(PipedInputStream inputStream) {
        try {
            System.out.println("read:");
            byte[] bytes = new byte[20];
            int read = inputStream.read(bytes);
            while (read != -1) {
                String str = new String(bytes, 0, read);
                System.out.println(str);
                read = inputStream.read(bytes);
            }
            System.out.println();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                inputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }

}
